]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Display the number of unread messages in the notification icon
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 27 Jun 2011 12:31:53 +0000 (14:31 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 7 Jul 2011 13:48:33 +0000 (15:48 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=654139

js/ui/telepathyClient.js

index 8a476011ae87170e5c86a41291518f0652ad3a15..b916fac6f14ba5ba43b1e578daea38ac278a1cae 100644 (file)
@@ -370,6 +370,8 @@ ChatSource.prototype = {
             this._pendingMessages.push(message);
         }
 
+        this._updateCount();
+
         let showTimestamp = false;
 
         for (let i = 0; i < logMessages.length; i++) {
@@ -414,11 +416,16 @@ ChatSource.prototype = {
         this.destroy();
     },
 
+    _updateCount: function() {
+        this._setCount(this._pendingMessages.length, this._pendingMessages.length > 0);
+    },
+
     _messageReceived: function(channel, message) {
         if (message.get_message_type() == Tp.ChannelTextMessageType.DELIVERY_REPORT)
             return;
 
         this._pendingMessages.push(message);
+        this._updateCount();
 
         message = makeMessageFromTpMessage(message, NotificationDirection.RECEIVED);
         this._notification.appendMessage(message);
@@ -489,8 +496,10 @@ ChatSource.prototype = {
     _pendingRemoved: function(channel, message) {
         let idx = this._pendingMessages.indexOf(message);
 
-        if (idx >= 0)
+        if (idx >= 0) {
             this._pendingMessages.splice(idx, 1);
+            this._updateCount();
+        }
         else
             throw new Error('Message not in our pending list: ' + message);
     },